package edu.hqu.deepspace.service;

import edu.hqu.deepspace.dao.AdminMapper;
import edu.hqu.deepspace.pojo.Admin;

import java.util.List;

public class AdminServiceImpl implements  AdminService{
    private AdminMapper adminMapper;

    public void setAdminMapper(AdminMapper adminMapper) {
        this.adminMapper = adminMapper;
    }


    @Override
    public Admin login(Admin admin) {
        Admin admin1 = adminMapper.getAdminByAdminname(admin.getName());
        if(admin.getName().trim()=="") {
            throw new RuntimeException("账号不可为空!!!");
        }
        if(admin.getPwd().trim()=="") {
            throw new RuntimeException("密码不可为空!!!");
        }
        if(admin1==null){
            throw new RuntimeException("账号不存在!!!");
        }
        if(admin1.getPwd().equals(admin.getPwd())){
            return admin1;
        }else{
            throw new RuntimeException("密码错误!!!");
        }
    }

}
